package cn.ubeta.b2c.settings;

import android.os.Bundle;
import android.view.View;

import cn.ubeta.b2c.R;
import cn.ubeta.b2c.api.ApiUser;
import cn.ubeta.b2c.bean.MeInfo;
import cn.ubeta.b2c.common.AnalyseActivity;
import cn.ubeta.b2c.user.address.AddressActivity;
import cn.ubeta.b2c.utils.Dlog;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by liudengyong on 16/8/28.
 */

public class SettingsActivity extends AnalyseActivity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState, R.layout.activity_settings);
        initView();
    }

    /**
     * 初始化视图
     */
    private void initView() {
        findViewById(R.id.tv_personal_info).setOnClickListener(this);
        findViewById(R.id.tv_personal_address).setOnClickListener(this);
        findViewById(R.id.tv_feedback).setOnClickListener(this);
        findViewById(R.id.rl_personal_about).setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        int id = view.getId();
        if (R.id.tv_personal_info == id) {
            // TODO retrofit测试
            ApiUser.postUserHeaderPic(new Callback<MeInfo>() {
                @Override
                public void onResponse(Call<MeInfo> call, Response<MeInfo> response) {
                    Dlog.e("onResponse 1");
                }

                @Override
                public void onFailure(Call<MeInfo> call, Throwable t) {
                    Dlog.e("onResponse 2");
                }
            });
            //OpenGlActivity.gotoActivity(this, OpenGlActivity.class);
        } else if (R.id.tv_personal_address == id) {
            AddressActivity.gotoActivity(this, AddressActivity.class);
        } else if (R.id.tv_feedback == id) {
            FeedbackActivity.gotoActivity(this, FeedbackActivity.class);
        } else if (R.id.rl_personal_about == id) {
            AboutActivity.gotoActivity(this, AboutActivity.class);
        }
    }
}
